'use strict';

const BaseController = require("../base");
const PosPhotoDto = require("../../dto/pos-photo.dto");
class PosPhotoController extends BaseController {
    /**
   * @description 图片入库
   * @param {PosPhotoDto.createDto} 查询参数
   */
    async create() {
        try {
            const verifytRes = this.verifytParams(PosPhotoDto.createDto);
            if (!verifytRes.success) throw verifytRes.msg;
            if (!Array.isArray(verifytRes.params.list)) throw '数据格式错误';
            const res = await this.service.ucenter.posPhoto.create(verifytRes.params);
            if (!res.success) throw res.msg;
            await this.success();

        } catch (err) {
            await this.error(err);
        }
    }

    /**
     * @description 分页查询列表
     * @param {PosPhotoDto.pageDto} 查询参数
     */
    async page() {
        try {
            const verifytRes = this.verifytParams(PosPhotoDto.pageDto);
            if (!verifytRes.success) throw verifytRes.msg;
            const res = await this.service.ucenter.posPhoto.page(verifytRes.params);
            if (!res.success) throw res.msg;
            await this.listSuccess(res.data.rows, res.data.count);
        } catch (err) {
            await this.error(err);
        }
    }
}

module.exports = PosPhotoController;
